<html>
<head><meta charset="utf-8"><title>Using RawVec directly · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html">Using RawVec directly</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238386376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/238386376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#238386376">(May 11 2021 at 21:41)</a>:</h4>
<p>I suspect I'm missing something obvious, but is there anyway to use RawVec directly? My main use case is in the compiler, but I can see it being useful externally as well</p>



<a name="238404783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/238404783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#238404783">(May 12 2021 at 00:59)</a>:</h4>
<p>With <code>Box&lt;[MaybeUninit]&gt;</code> you'll have to implement resizing yourself.  <code>Vec</code> comes with the extra length field. So there's nothing public with comparable capabilities.<br>
You could use it with a feature gate, but those annotations say you shouldn't. <a href="https://github.com/rust-lang/rust/blob/master/library/alloc/src/raw_vec.rs#L1-L2">https://github.com/rust-lang/rust/blob/master/library/alloc/src/raw_vec.rs#L1-L2</a></p>



<a name="238406282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/238406282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#238406282">(May 12 2021 at 01:16)</a>:</h4>
<p>converting between vec and box would give the full capabilities, but it's a bit ugly.</p>



<a name="239391585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/239391585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#239391585">(May 19 2021 at 09:21)</a>:</h4>
<p>Semi related, why is <code>RawVec</code> even public and not pub crate?</p>



<a name="239395896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/239395896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#239395896">(May 19 2021 at 09:57)</a>:</h4>
<p>Looking at the commit that made it <code>doc(hidden)</code> there used to be a libarena referencing rawvec. Since that's gone maybe there no longer is any reason.</p>



<a name="239396107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/239396107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giacomo Stevanato <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#239396107">(May 19 2021 at 09:59)</a>:</h4>
<p>I find it weird that the <code>doc(hidden)</code> and <code>unstable</code> attributes are in <code>raw_vec.rs</code> instead of the <code>pub mod raw_vec</code> module declaration</p>



<a name="239396606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/239396606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#239396606">(May 19 2021 at 10:02)</a>:</h4>
<p>might be worth a PR to make it private. although hidden + unstable + no tracking issue effectively means zero stability guarantees anyway.</p>



<a name="239463538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Using%20RawVec%20directly/near/239463538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Using.20RawVec.20directly.html#239463538">(May 19 2021 at 17:20)</a>:</h4>
<p>I think posting such a PR and running it through crater seems like a good idea.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>